package tests;

import junit.framework.TestCase;
import srw.MainFrame;
import srw.Property;
import utils.TreeUtils;

public class TreeTest extends TestCase {
	
	Property _root;

//	@Override
//	protected void setUp() throws Exception {
//	}

	public void testReadTree(){
		Property.clear();
		_root = TreeUtils.readTree(MainFrame._FilesPath + "properties_tree.txt");
		
		assertEquals(null, Property.getByName("d").getParent());
		assertEquals(null, Property.getByName("y").getParent());
		assertEquals(Property.getByName("y"), Property.getByName("g").getParent());
		assertEquals(Property.getByName("g"), Property.getByName("u").getParent());
		assertEquals(null, Property.getByName("f").getParent());
		assertEquals(Property.getByName("f"), Property.getByName("k").getParent());
		assertEquals(Property.getByName("k"), Property.getByName("i").getParent());
		assertEquals(Property.getByName("k"), Property.getByName("o").getParent());
		assertEquals(Property.getByName("f"), Property.getByName("p").getParent());
		
	}
	
	public void testReadTree1(){
		Property.clear();
		_root = TreeUtils.readTree(MainFrame._FilesPath + "test1.txt");
		
		assertEquals(null, Property.getByName("a").getParent());
		assertEquals(Property.getByName("a"), Property.getByName("b").getParent());		
	}
	
	public void testPropertyFabrique(){
		Property.clear();
		assertNull(Property.getByName("a"));
		Property p = Property.createNew("a");
		assertEquals(Property.getByName("a"), p);
	}

}
